package com.moose.operator.web.service.impl.poetry;

import com.moose.operator.common.QueryWrapper;
import com.moose.operator.model.entity.PoetryItemDetail;
import com.moose.operator.web.service.PoetryItemDetailService;
import javax.annotation.Resource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

/**
 * @author taohua
 */
@Service
public class PoetryItemDetailServiceImpl implements PoetryItemDetailService {

  @Resource
  private MongoTemplate mongoTemplate;

  @Override public PoetryItemDetail getDetailByPoetryId(Integer poetryId) {
    Query query = QueryWrapper.buildQuery();
    Criteria criteria = Criteria.where("poetry_id").is(poetryId);
    query.addCriteria(criteria);
    return mongoTemplate.findOne(query, PoetryItemDetail.class);
  }
}
